package com.starsea.book.ui.newpage.pop

import android.content.Context
import android.text.TextUtils
import android.widget.TextView
import com.blankj.utilcode.util.ScreenUtils
import com.lxj.xpopup.core.BottomPopupView
import com.starsea.book.R
import com.starsea.book.ui.newpage.normalview.RadiusTextView

/**
 * @author Lee
 * @createTime 2023-08-04 16 GMT+8
 * @desc :
 */
class PhotoChosePop(

  var mContext: Context,
  var mCallBack: ClickCallBack,
  var first: String = "",
  var two: String = ""
) :
  BottomPopupView(mContext) {

  override fun getImplLayoutId(): Int {
    return R.layout.layout_photo_choose_pop
  }

  override fun onCreate() {
    super.onCreate()
    findViewById<TextView>(R.id.rtv_cancel)
      .setOnClickListener {
        dismiss()
      }

    var rtv_photo_pic = findViewById<RadiusTextView>(R.id.rtv_photo_pic)
    var rtv_camera = findViewById<RadiusTextView>(R.id.rtv_camera)

    if (!TextUtils.isEmpty(first)) {
      rtv_photo_pic.text = first
    }
    if (!TextUtils.isEmpty(two)) {
      rtv_camera.text = two
    }

    rtv_photo_pic
      .setOnClickListener {
        mCallBack.onClick(1)
        dismiss()
      }

    rtv_camera
      .setOnClickListener {
        mCallBack.onClick(2)
        dismiss()
      }

  }

  override fun getMaxHeight(): Int {
    return ScreenUtils.getScreenHeight() / 2
  }

  interface ClickCallBack {
    fun onClick(type: Int)

  }

}